\hypertarget{group__flash__api}{
\section{Flash\_\-api}
\label{group__flash__api}\index{Flash\_\-api@{Flash\_\-api}}
}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
unsigned long \hyperlink{group__flash__api_gac8ad2e852a02e893689092a8ef142ced}{FlashUsecGet} (void)
\item 
void \hyperlink{group__flash__api_ga15aef055abddb84a89434bccc8ee04af}{FlashUsecSet} (unsigned long ulClocks)
\item 
long \hyperlink{group__flash__api_gab6909ecd136848c37439a5cc80c97557}{FlashErase} (unsigned long ulAddress)
\item 
long \hyperlink{group__flash__api_gab5ebae9913ed28d20e28343b40451d71}{FlashProgram} (unsigned long $\ast$pulData, unsigned long ulAddress, unsigned long ulCount)
\item 
tFlashProtection \hyperlink{group__flash__api_ga58121113dac17627493a0956fe787cb0}{FlashProtectGet} (unsigned long ulAddress)
\item 
long \hyperlink{group__flash__api_ga149a8aa92ff4cb90f6c5fa834fe0005c}{FlashProtectSet} (unsigned long ulAddress, tFlashProtection eProtect)
\item 
long \hyperlink{group__flash__api_ga55d2dc9c8e0491df929ac50df8bb8a34}{FlashProtectSave} (void)
\item 
long \hyperlink{group__flash__api_ga91c03c5f9e26f0ceb5767e312fe7c4df}{FlashUserGet} (unsigned long $\ast$pulUser0, unsigned long $\ast$pulUser1)
\item 
long \hyperlink{group__flash__api_ga6ba4d65f314cf791352a7d12a94bcc7c}{FlashUserSet} (unsigned long ulUser0, unsigned long ulUser1)
\item 
long \hyperlink{group__flash__api_ga345c31a893e32b26e24c8b9c29cd435d}{FlashUserSave} (void)
\item 
void \hyperlink{group__flash__api_gadc9618455a71ab80e02dd0139a30767b}{FlashIntRegister} (void($\ast$pfnHandler)(void))
\item 
void \hyperlink{group__flash__api_gaeeef7616c7db14cc8f1b21de1a777e10}{FlashIntUnregister} (void)
\item 
void \hyperlink{group__flash__api_ga5d5084bdc97141ff60048b5688823eed}{FlashIntEnable} (unsigned long ulIntFlags)
\item 
void \hyperlink{group__flash__api_gae72218a0782cb80a4d45cf4372571e2d}{FlashIntDisable} (unsigned long ulIntFlags)
\item 
unsigned long \hyperlink{group__flash__api_gafa97f99d51af28e10fed79c062dc7cfb}{FlashIntGetStatus} (tBoolean bMasked)
\item 
void \hyperlink{group__flash__api_ga711b65c34a7d4a1f151e7fca19b68c31}{FlashIntClear} (unsigned long ulIntFlags)
\end{DoxyCompactItemize}


\subsection{Function Documentation}
\hypertarget{group__flash__api_gab6909ecd136848c37439a5cc80c97557}{
\index{flash\_\-api@{flash\_\-api}!FlashErase@{FlashErase}}
\index{FlashErase@{FlashErase}!flash_api@{flash\_\-api}}
\subsubsection[{FlashErase}]{\setlength{\rightskip}{0pt plus 5cm}long FlashErase (
\begin{DoxyParamCaption}
\item[{unsigned long}]{ ulAddress}
\end{DoxyParamCaption}
)}}
\label{group__flash__api_gab6909ecd136848c37439a5cc80c97557}
Erases a block of flash.


\begin{DoxyParams}{Parameters}
\item[{\em ulAddress}]is the start address of the flash block to be erased.\end{DoxyParams}
This function will erase a 1 kB block of the on-\/chip flash. After erasing, the block will be filled with 0xFF bytes. Read-\/only and execute-\/only blocks cannot be erased.

This function will not return until the block has been erased.

\begin{DoxyReturn}{Returns}
Returns 0 on success, or -\/1 if an invalid block address was specified or the block is write-\/protected. 
\end{DoxyReturn}
\hypertarget{group__flash__api_ga711b65c34a7d4a1f151e7fca19b68c31}{
\index{flash\_\-api@{flash\_\-api}!FlashIntClear@{FlashIntClear}}
\index{FlashIntClear@{FlashIntClear}!flash_api@{flash\_\-api}}
\subsubsection[{FlashIntClear}]{\setlength{\rightskip}{0pt plus 5cm}void FlashIntClear (
\begin{DoxyParamCaption}
\item[{unsigned long}]{ ulIntFlags}
\end{DoxyParamCaption}
)}}
\label{group__flash__api_ga711b65c34a7d4a1f151e7fca19b68c31}
Clears flash controller interrupt sources.


\begin{DoxyParams}{Parameters}
\item[{\em ulIntFlags}]is the bit mask of the interrupt sources to be cleared. Can be any of the {\bfseries FLASH\_\-FCMISC\_\-PROGRAM} or {\bfseries FLASH\_\-FCMISC\_\-AMISC} values.\end{DoxyParams}
The specified flash controller interrupt sources are cleared, so that they no longer assert. This must be done in the interrupt handler to keep it from being called again immediately upon exit.

\begin{DoxyNote}{Note}
Since there is a write buffer in the Cortex-\/M3 processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (since NVIC still sees the interrupt source asserted).
\end{DoxyNote}
\begin{DoxyReturn}{Returns}
None. 
\end{DoxyReturn}
\hypertarget{group__flash__api_gae72218a0782cb80a4d45cf4372571e2d}{
\index{flash\_\-api@{flash\_\-api}!FlashIntDisable@{FlashIntDisable}}
\index{FlashIntDisable@{FlashIntDisable}!flash_api@{flash\_\-api}}
\subsubsection[{FlashIntDisable}]{\setlength{\rightskip}{0pt plus 5cm}void FlashIntDisable (
\begin{DoxyParamCaption}
\item[{unsigned long}]{ ulIntFlags}
\end{DoxyParamCaption}
)}}
\label{group__flash__api_gae72218a0782cb80a4d45cf4372571e2d}
Disables individual flash controller interrupt sources.


\begin{DoxyParams}{Parameters}
\item[{\em ulIntFlags}]is a bit mask of the interrupt sources to be disabled. Can be any of the {\bfseries FLASH\_\-FCIM\_\-PROGRAM} or {\bfseries FLASH\_\-FCIM\_\-ACCESS} values.\end{DoxyParams}
Disables the indicated flash controller interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

\begin{DoxyReturn}{Returns}
None. 
\end{DoxyReturn}
\hypertarget{group__flash__api_ga5d5084bdc97141ff60048b5688823eed}{
\index{flash\_\-api@{flash\_\-api}!FlashIntEnable@{FlashIntEnable}}
\index{FlashIntEnable@{FlashIntEnable}!flash_api@{flash\_\-api}}
\subsubsection[{FlashIntEnable}]{\setlength{\rightskip}{0pt plus 5cm}void FlashIntEnable (
\begin{DoxyParamCaption}
\item[{unsigned long}]{ ulIntFlags}
\end{DoxyParamCaption}
)}}
\label{group__flash__api_ga5d5084bdc97141ff60048b5688823eed}
Enables individual flash controller interrupt sources.


\begin{DoxyParams}{Parameters}
\item[{\em ulIntFlags}]is a bit mask of the interrupt sources to be enabled. Can be any of the {\bfseries FLASH\_\-FCIM\_\-PROGRAM} or {\bfseries FLASH\_\-FCIM\_\-ACCESS} values.\end{DoxyParams}
Enables the indicated flash controller interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

\begin{DoxyReturn}{Returns}
None. 
\end{DoxyReturn}
\hypertarget{group__flash__api_gafa97f99d51af28e10fed79c062dc7cfb}{
\index{flash\_\-api@{flash\_\-api}!FlashIntGetStatus@{FlashIntGetStatus}}
\index{FlashIntGetStatus@{FlashIntGetStatus}!flash_api@{flash\_\-api}}
\subsubsection[{FlashIntGetStatus}]{\setlength{\rightskip}{0pt plus 5cm}unsigned long FlashIntGetStatus (
\begin{DoxyParamCaption}
\item[{tBoolean}]{ bMasked}
\end{DoxyParamCaption}
)}}
\label{group__flash__api_gafa97f99d51af28e10fed79c062dc7cfb}
Gets the current interrupt status.


\begin{DoxyParams}{Parameters}
\item[{\em bMasked}]is false if the raw interrupt status is required and true if the masked interrupt status is required.\end{DoxyParams}
This returns the interrupt status for the flash controller. Either the raw interrupt status or the status of interrupts that are allowed to reflect to the processor can be returned.

\begin{DoxyReturn}{Returns}
The current interrupt status, enumerated as a bit field of {\bfseries FLASH\_\-FCMISC\_\-PROGRAM} and {\bfseries FLASH\_\-FCMISC\_\-AMISC}. 
\end{DoxyReturn}
\hypertarget{group__flash__api_gadc9618455a71ab80e02dd0139a30767b}{
\index{flash\_\-api@{flash\_\-api}!FlashIntRegister@{FlashIntRegister}}
\index{FlashIntRegister@{FlashIntRegister}!flash_api@{flash\_\-api}}
\subsubsection[{FlashIntRegister}]{\setlength{\rightskip}{0pt plus 5cm}void FlashIntRegister (
\begin{DoxyParamCaption}
\item[{void($\ast$)(void)}]{ pfnHandler}
\end{DoxyParamCaption}
)}}
\label{group__flash__api_gadc9618455a71ab80e02dd0139a30767b}
Registers an interrupt handler for the flash interrupt.


\begin{DoxyParams}{Parameters}
\item[{\em pfnHandler}]is a pointer to the function to be called when the flash interrupt occurs.\end{DoxyParams}
This sets the handler to be called when the flash interrupt occurs. The flash controller can generate an interrupt when an invalid flash access occurs, such as trying to program or erase a read-\/only block, or trying to read from an execute-\/only block. It can also generate an interrupt when a program or erase operation has completed. The interrupt will be automatically enabled when the handler is registered.

\begin{DoxySeeAlso}{See also}
\hyperlink{group__interrupt__api_ga471d00d73ae22faa426c202f608e9c69}{IntRegister()} for important information about registering interrupt handlers.
\end{DoxySeeAlso}
\begin{DoxyReturn}{Returns}
None. 
\end{DoxyReturn}
\hypertarget{group__flash__api_gaeeef7616c7db14cc8f1b21de1a777e10}{
\index{flash\_\-api@{flash\_\-api}!FlashIntUnregister@{FlashIntUnregister}}
\index{FlashIntUnregister@{FlashIntUnregister}!flash_api@{flash\_\-api}}
\subsubsection[{FlashIntUnregister}]{\setlength{\rightskip}{0pt plus 5cm}void FlashIntUnregister (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}}
\label{group__flash__api_gaeeef7616c7db14cc8f1b21de1a777e10}
Unregisters the interrupt handler for the flash interrupt.

This function will clear the handler to be called when the flash interrupt occurs. This will also mask off the interrupt in the interrupt controller so that the interrupt handler is no longer called.

\begin{DoxySeeAlso}{See also}
\hyperlink{group__interrupt__api_ga471d00d73ae22faa426c202f608e9c69}{IntRegister()} for important information about registering interrupt handlers.
\end{DoxySeeAlso}
\begin{DoxyReturn}{Returns}
None. 
\end{DoxyReturn}
\hypertarget{group__flash__api_gab5ebae9913ed28d20e28343b40451d71}{
\index{flash\_\-api@{flash\_\-api}!FlashProgram@{FlashProgram}}
\index{FlashProgram@{FlashProgram}!flash_api@{flash\_\-api}}
\subsubsection[{FlashProgram}]{\setlength{\rightskip}{0pt plus 5cm}long FlashProgram (
\begin{DoxyParamCaption}
\item[{unsigned long $\ast$}]{ pulData, }
\item[{unsigned long}]{ ulAddress, }
\item[{unsigned long}]{ ulCount}
\end{DoxyParamCaption}
)}}
\label{group__flash__api_gab5ebae9913ed28d20e28343b40451d71}
Programs flash.


\begin{DoxyParams}{Parameters}
\item[{\em pulData}]is a pointer to the data to be programmed. \item[{\em ulAddress}]is the starting address in flash to be programmed. Must be a multiple of four. \item[{\em ulCount}]is the number of bytes to be programmed. Must be a multiple of four.\end{DoxyParams}
This function will program a sequence of words into the on-\/chip flash. Programming each location consists of the result of an AND operation of the new data and the existing data; in other words bits that contain 1 can remain 1 or be changed to 0, but bits that are 0 cannot be changed to 1. Therefore, a word can be programmed multiple times as long as these rules are followed; if a program operation attempts to change a 0 bit to a 1 bit, that bit will not have its value changed.

Since the flash is programmed one word at a time, the starting address and byte count must both be multiples of four. It is up to the caller to verify the programmed contents, if such verification is required.

This function will not return until the data has been programmed.

\begin{DoxyReturn}{Returns}
Returns 0 on success, or -\/1 if a programming error is encountered. 
\end{DoxyReturn}
\hypertarget{group__flash__api_ga58121113dac17627493a0956fe787cb0}{
\index{flash\_\-api@{flash\_\-api}!FlashProtectGet@{FlashProtectGet}}
\index{FlashProtectGet@{FlashProtectGet}!flash_api@{flash\_\-api}}
\subsubsection[{FlashProtectGet}]{\setlength{\rightskip}{0pt plus 5cm}tFlashProtection FlashProtectGet (
\begin{DoxyParamCaption}
\item[{unsigned long}]{ ulAddress}
\end{DoxyParamCaption}
)}}
\label{group__flash__api_ga58121113dac17627493a0956fe787cb0}
Gets the protection setting for a block of flash.


\begin{DoxyParams}{Parameters}
\item[{\em ulAddress}]is the start address of the flash block to be queried.\end{DoxyParams}
This function will get the current protection for the specified 2 kB block of flash. Each block can be read/write, read-\/only, or execute-\/only. Read/write blocks can be read, executed, erased, and programmed. Read-\/only blocks can be read and executed. Execute-\/only blocks can only be executed; processor and debugger data reads are not allowed.

\begin{DoxyReturn}{Returns}
Returns the protection setting for this block. See \hyperlink{group__flash__api_ga149a8aa92ff4cb90f6c5fa834fe0005c}{FlashProtectSet()} for possible values. 
\end{DoxyReturn}
\hypertarget{group__flash__api_ga55d2dc9c8e0491df929ac50df8bb8a34}{
\index{flash\_\-api@{flash\_\-api}!FlashProtectSave@{FlashProtectSave}}
\index{FlashProtectSave@{FlashProtectSave}!flash_api@{flash\_\-api}}
\subsubsection[{FlashProtectSave}]{\setlength{\rightskip}{0pt plus 5cm}long FlashProtectSave (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}}
\label{group__flash__api_ga55d2dc9c8e0491df929ac50df8bb8a34}
Saves the flash protection settings.

This function will make the currently programmed flash protection settings permanent. This is a non-\/reversible operation; a chip reset or power cycle will not change the flash protection.

This function will not return until the protection has been saved.

\begin{DoxyReturn}{Returns}
Returns 0 on success, or -\/1 if a hardware error is encountered. 
\end{DoxyReturn}
\hypertarget{group__flash__api_ga149a8aa92ff4cb90f6c5fa834fe0005c}{
\index{flash\_\-api@{flash\_\-api}!FlashProtectSet@{FlashProtectSet}}
\index{FlashProtectSet@{FlashProtectSet}!flash_api@{flash\_\-api}}
\subsubsection[{FlashProtectSet}]{\setlength{\rightskip}{0pt plus 5cm}long FlashProtectSet (
\begin{DoxyParamCaption}
\item[{unsigned long}]{ ulAddress, }
\item[{tFlashProtection}]{ eProtect}
\end{DoxyParamCaption}
)}}
\label{group__flash__api_ga149a8aa92ff4cb90f6c5fa834fe0005c}
Sets the protection setting for a block of flash.


\begin{DoxyParams}{Parameters}
\item[{\em ulAddress}]is the start address of the flash block to be protected. \item[{\em eProtect}]is the protection to be applied to the block. Can be one of {\bfseries FlashReadWrite}, {\bfseries FlashReadOnly}, or {\bfseries FlashExecuteOnly}.\end{DoxyParams}
This function will set the protection for the specified 2 kB block of flash. Blocks which are read/write can be made read-\/only or execute-\/only. Blocks which are read-\/only can be made execute-\/only. Blocks which are execute-\/only cannot have their protection modified. Attempts to make the block protection less stringent (that is, read-\/only to read/write) will result in a failure (and be prevented by the hardware).

Changes to the flash protection are maintained only until the next reset. This allows the application to be executed in the desired flash protection environment to check for inappropriate flash access (via the flash interrupt). To make the flash protection permanent, use the \hyperlink{group__flash__api_ga55d2dc9c8e0491df929ac50df8bb8a34}{FlashProtectSave()} function.

\begin{DoxyReturn}{Returns}
Returns 0 on success, or -\/1 if an invalid address or an invalid protection was specified. 
\end{DoxyReturn}
\hypertarget{group__flash__api_gac8ad2e852a02e893689092a8ef142ced}{
\index{flash\_\-api@{flash\_\-api}!FlashUsecGet@{FlashUsecGet}}
\index{FlashUsecGet@{FlashUsecGet}!flash_api@{flash\_\-api}}
\subsubsection[{FlashUsecGet}]{\setlength{\rightskip}{0pt plus 5cm}unsigned long FlashUsecGet (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}}
\label{group__flash__api_gac8ad2e852a02e893689092a8ef142ced}
Gets the number of processor clocks per micro-\/second.

This function returns the number of clocks per micro-\/second, as presently known by the flash controller.

\begin{DoxyReturn}{Returns}
Returns the number of processor clocks per micro-\/second. 
\end{DoxyReturn}
\hypertarget{group__flash__api_ga15aef055abddb84a89434bccc8ee04af}{
\index{flash\_\-api@{flash\_\-api}!FlashUsecSet@{FlashUsecSet}}
\index{FlashUsecSet@{FlashUsecSet}!flash_api@{flash\_\-api}}
\subsubsection[{FlashUsecSet}]{\setlength{\rightskip}{0pt plus 5cm}void FlashUsecSet (
\begin{DoxyParamCaption}
\item[{unsigned long}]{ ulClocks}
\end{DoxyParamCaption}
)}}
\label{group__flash__api_ga15aef055abddb84a89434bccc8ee04af}
Sets the number of processor clocks per micro-\/second.


\begin{DoxyParams}{Parameters}
\item[{\em ulClocks}]is the number of processor clocks per micro-\/second.\end{DoxyParams}
This function is used to tell the flash controller the number of processor clocks per micro-\/second. This value must be programmed correctly or the flash most likely will not program correctly; it has no affect on reading flash.

\begin{DoxyReturn}{Returns}
None. 
\end{DoxyReturn}
\hypertarget{group__flash__api_ga91c03c5f9e26f0ceb5767e312fe7c4df}{
\index{flash\_\-api@{flash\_\-api}!FlashUserGet@{FlashUserGet}}
\index{FlashUserGet@{FlashUserGet}!flash_api@{flash\_\-api}}
\subsubsection[{FlashUserGet}]{\setlength{\rightskip}{0pt plus 5cm}long FlashUserGet (
\begin{DoxyParamCaption}
\item[{unsigned long $\ast$}]{ pulUser0, }
\item[{unsigned long $\ast$}]{ pulUser1}
\end{DoxyParamCaption}
)}}
\label{group__flash__api_ga91c03c5f9e26f0ceb5767e312fe7c4df}
Gets the user registers.


\begin{DoxyParams}{Parameters}
\item[{\em pulUser0}]is a pointer to the location to store USER Register 0. \item[{\em pulUser1}]is a pointer to the location to store USER Register 1.\end{DoxyParams}
This function will read the contents of user registers (0 and 1), and store them in the specified locations.

\begin{DoxyReturn}{Returns}
Returns 0 on success, or -\/1 if a hardware error is encountered. 
\end{DoxyReturn}
\hypertarget{group__flash__api_ga345c31a893e32b26e24c8b9c29cd435d}{
\index{flash\_\-api@{flash\_\-api}!FlashUserSave@{FlashUserSave}}
\index{FlashUserSave@{FlashUserSave}!flash_api@{flash\_\-api}}
\subsubsection[{FlashUserSave}]{\setlength{\rightskip}{0pt plus 5cm}long FlashUserSave (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}}
\label{group__flash__api_ga345c31a893e32b26e24c8b9c29cd435d}
Saves the user registers.

This function will make the currently programmed user register settings permanent. This is a non-\/reversible operation; a chip reset or power cycle will not change this setting.

This function will not return until the protection has been saved.

\begin{DoxyReturn}{Returns}
Returns 0 on success, or -\/1 if a hardware error is encountered. 
\end{DoxyReturn}
\hypertarget{group__flash__api_ga6ba4d65f314cf791352a7d12a94bcc7c}{
\index{flash\_\-api@{flash\_\-api}!FlashUserSet@{FlashUserSet}}
\index{FlashUserSet@{FlashUserSet}!flash_api@{flash\_\-api}}
\subsubsection[{FlashUserSet}]{\setlength{\rightskip}{0pt plus 5cm}long FlashUserSet (
\begin{DoxyParamCaption}
\item[{unsigned long}]{ ulUser0, }
\item[{unsigned long}]{ ulUser1}
\end{DoxyParamCaption}
)}}
\label{group__flash__api_ga6ba4d65f314cf791352a7d12a94bcc7c}
Sets the user registers.


\begin{DoxyParams}{Parameters}
\item[{\em ulUser0}]is the value to store in USER Register 0. \item[{\em ulUser1}]is the value to store in USER Register 1.\end{DoxyParams}
This function will set the contents of the user registers (0 and 1) to the specified values.

\begin{DoxyReturn}{Returns}
Returns 0 on success, or -\/1 if a hardware error is encountered. 
\end{DoxyReturn}
